package com.it.controller.admin;

import com.it.bean.R;
import com.it.dao.UserMapper;
import com.it.dao.UserTokenMapper;
import com.it.params.TestQuery;
import com.it.pojo.User;
import com.it.pojo.vo.AdminUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;

@CrossOrigin
@RequestMapping("test")
@RestController
@Api(value = "测试")
public class Test {


    @Resource
    private UserMapper userMapper;
    private Integer a;
    @Resource
    private UserTokenMapper userTokenMapper;

    @ApiOperation(value = "v1测试接口")
    @RequestMapping("v1")
    public R v1() {
        List<User> users = userMapper.selectList(null);
        User user = users.get(1);
        System.out.println("user = " + user);
        Date gmtCreate = user.getGmtCreate();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = simpleDateFormat.format(gmtCreate);
        System.out.println("format = " + format);
        users.forEach(System.out::println);
        return null;
    }

    @ApiOperation(value = "v2测试接口")
    @PostMapping("v2")
    public R v2(@RequestBody TestQuery testQuery) {
//        List<User> users = userMapper.listUser();
//        users.stream().forEach(System.out::println);
        return null;
    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String next = scanner.next();
        System.out.println("next = " + next);
        String next1 = scanner.next();
        System.out.println("next1 = " + next1);

//        System.out.println("i = " + i);

    }
}
